package edu.washington.tcss360.burningpenguins.util;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import edu.washington.tcss360.burningpenguins.client.ConferenceClient;
import edu.washington.tcss360.burningpenguins.client.PermissionClient;
import edu.washington.tcss360.burningpenguins.client.RoleClient;
import edu.washington.tcss360.burningpenguins.client.UserClient;
import edu.washington.tcss360.burningpenguins.data.Conference;
import edu.washington.tcss360.burningpenguins.data.Permission;
import edu.washington.tcss360.burningpenguins.data.Role;
import edu.washington.tcss360.burningpenguins.data.User;
import edu.washington.tcss360.burningpenguins.database.BPDatabaseConnection;
import edu.washington.tcss360.burningpenguins.database.BPSQLiteConnection;
import edu.washington.tcss360.burningpenguins.queries.ByConferenceId;
import edu.washington.tcss360.burningpenguins.queries.ByEmail;
import edu.washington.tcss360.burningpenguins.queries.ByFirstName;
import edu.washington.tcss360.burningpenguins.queries.ById;
import edu.washington.tcss360.burningpenguins.queries.ByUserId;
import edu.washington.tcss360.burningpenguins.queries.ByLastName;
import edu.washington.tcss360.burningpenguins.queries.ByUsername;
import edu.washington.tcss360.burningpenguins.queries.QueryBy;

/**
 * Initializes a database for use with the application and inserts seed data into it.
 * 
 * @author Chris Gelatt
 * @version 1.0
 * @since 2013-11-2
 *
 */
public class SeedData
{
	/**
	 * Initializes the database for use with this application.
	 * <p>
	 * This method will drop all the tables for this application before recreating them.
	 * 
	 * @param connection A database connection to use for the initialization.
	 */
	public static void initializeDatabase(BPDatabaseConnection connection)
	{
		connection.executeUpdate("DROP TABLE IF EXISTS User;");
		connection.executeUpdate("CREATE TABLE User(Id INTEGER PRIMARY KEY AUTOINCREMENT, Username STRING, Email STRING, FirstName STRING, LastName STRING);");
		connection.executeUpdate("DROP TABLE IF EXISTS Conference;");
		connection.executeUpdate("CREATE TABLE Conference(Id INTEGER PRIMARY KEY AUTOINCREMENT, Title STRING, Description STRING, SubmitDeadline INT8, ReviewDeadline INT8, RecommendDeadline INT8, AcceptDeadline INT8, UpdateDeadline INT8);");
		connection.executeUpdate("DROP TABLE IF EXISTS Role;");
		connection.executeUpdate("CREATE TABLE Role(Id INTEGER PRIMARY KEY AUTOINCREMENT, Title STRING);");
		connection.executeUpdate("DROP TABLE IF EXISTS Permission;");
		connection.executeUpdate("CREATE TABLE Permission(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, RoleId INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS Paper;");
		connection.executeUpdate("CREATE TABLE Paper(Id INTEGER PRIMARY KEY AUTOINCREMENT, UserId INTEGER, ConferenceId INTEGER, Title STRING, PaperAbstract STRING, PaperFilePath STRING, PaperAcceptanceStatus INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS Category;");
		connection.executeUpdate("CREATE TABLE Category(Id INTEGER PRIMARY KEY AUTOINCREMENT, Title STRING);");
		connection.executeUpdate("DROP TABLE IF EXISTS Review;");
		connection.executeUpdate("CREATE TABLE Review(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, PaperId INTEGER, Question1 STRING, Rating1 INTEGER, Question2 STRING, Rating2 INTEGER, Question3 STRING, Rating3 INTEGER, Question4 STRING, Rating4 INTEGER, Question5 STRING, Rating5 INTEGER, Question6 STRING, Rating6 INTEGER, Question7 STRING, Rating7 INTEGER, Question8 STRING, Rating8 INTEGER, Question9 STRING, Rating9 INTEGER, SummaryRating INTEGER, SummaryComments STRING);");
		connection.executeUpdate("DROP TABLE IF EXISTS Recommendation;");
		connection.executeUpdate("CREATE TABLE Recommendation(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, PaperId INTEGER, RecommendationRating INTEGER, RecommendationComments STRING);");
		connection.executeUpdate("DROP TABLE IF EXISTS ConferenceCategory;");
		connection.executeUpdate("CREATE TABLE ConferenceCategory(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, CategoryId INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS PaperCategory;");
		connection.executeUpdate("CREATE TABLE PaperCategory(Id INTEGER PRIMARY KEY AUTOINCREMENT, PaperId INTEGER, CategoryId INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS Approval;");
		connection.executeUpdate("CREATE TABLE Approval(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, PaperId INTEGER, PaperApproval INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS ReviewAssignment;");
		connection.executeUpdate("CREATE TABLE ReviewAssignment(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, ConferenceId INTEGER, PaperId INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS ReviewDesignation;");
		connection.executeUpdate("CREATE TABLE ReviewDesignation(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, ConferenceId INTEGER, PaperId INTEGER);");
		connection.executeUpdate("DROP TABLE IF EXISTS RecommendationAssignment;");
		connection.executeUpdate("CREATE TABLE RecommendationAssignment(Id INTEGER PRIMARY KEY AUTOINCREMENT, ConferenceId INTEGER, UserId INTEGER, PaperId INTEGER);");
	}
	
	/**
	 * Inserts seed data into the database.
	 * 
	 * @param connection The connection to use for the seed data run.
	 */
	public static void runSeedData(BPDatabaseConnection connection)
	{
		seedConferences(connection);
		seedUsers(connection);
		seedRoles(connection);
		seedPermissions(connection);
	}
	
	/**
	 * Resets the sequence number for the ID column of the specified table to continue incrementing after the current highest value.
	 * 
	 * @param connection The connection to use for the operation.
	 * @param tableName The name of the table to alter the sequence number.
	 */
	public static void resetIdSequence(BPDatabaseConnection connection, String tableName)
	{
		try
		{
			ResultSet currentIdResult = connection.executeQuery("SELECT Id FROM " + tableName + " ORDER BY Id DESC LIMIT 1;");
			Integer currentId = 0;
			if(currentIdResult.next())
			{
				currentId = currentIdResult.getInt("Id");
			}
			
			// If we have an ID, then there's data in the table.  Otherwise, there's no point
			// in adjusting the sequence ID.
			if(currentId > 0)
			{
				ResultSet currentSequenceNumber = connection.executeQuery("SELECT seq FROM sqlite_sequence WHERE name='" + tableName + "';");
				
				// Make sure there's already an entry in the sequence table for this table.
				// If not, we'll have to create one.
				if(currentSequenceNumber.next())
				{
					connection.executeUpdate("UPDATE sqlite_sequence SET seq=" + currentId + " WHERE name='" + tableName + "';");
				}
				else
				{
					connection.executeUpdate("INSERT INTO sqlite_sequence VALUES (" + currentId + ", '" + tableName + "');");
				}
			}
		}
		catch(SQLException e)
		{
			e.printStackTrace();
		}
	}
	
	/**
	 * Inserts the seed conferences into the database.
	 * 
	 * @param connection The connection to use for the seed data run.
	 */
	public static void seedConferences(BPDatabaseConnection connection)
	{
		connection.executeUpdate("INSERT INTO Conference VALUES (4, 'OOPSLA', 'Object-Oriented Programming, Systems, Languages & Applications', 1387165284000, 1387251684000, 1387338084000, 1387424484000, 1387510884000);");
		connection.executeUpdate("INSERT INTO Conference VALUES (7, 'TechEd', 'TechEd', 1387165284000, 1387251684000, 1387338084000, 1387424484000, 1387510884000);");
		connection.executeUpdate("INSERT INTO Conference VALUES (8, 'ICMEE', 'International Conference for Mechanical Engineering Education', 1387165284000, 1387251684000, 1387338084000, 1387424484000, 1387510884000);");
		connection.executeUpdate("INSERT INTO Conference VALUES (9, 'BSCSE', 'Baltic States Conference on Software Engineering', 1387165284000, 1387251684000, 1387338084000, 1387424484000, 1387510884000);");
		connection.executeUpdate("INSERT INTO Conference VALUES (10, 'LAS', 'LearningAtScale', 1387165284000, 1387251684000, 1387338084000, 1387424484000, 1387510884000);");
		resetIdSequence(connection, "Conference");
	}
	
	/**
	 * Inserts the seed users into the database.
	 * 
	 * @param connection The connection to use for the seed data run.
	 */
	public static void seedUsers(BPDatabaseConnection connection)
	{
		connection.executeUpdate("INSERT INTO User VALUES (14, 'Thomas.Alexander@potlatchcorp.com', 'Thomas.Alexander@potlatchcorp.com', 'Thomas', 'Alexander');");
		connection.executeUpdate("INSERT INTO User VALUES (17, 'Maria.Allen@yahoo.com', 'Maria.Allen@yahoo.com', 'Maria', 'Allen');");
		connection.executeUpdate("INSERT INTO User VALUES (15, 'James_Allen@microsoft.com', 'James_Allen@microsoft.com', 'James', 'Allen');");
		connection.executeUpdate("INSERT INTO User VALUES (16, 'JAllen@starbucks.com', 'JAllen@starbucks.com', 'John', 'Allen');");
		connection.executeUpdate("INSERT INTO User VALUES (18, 'DennisAllison@wellsfargo.com', 'DennisAllison@wellsfargo.com', 'Dennis', 'Allison');");
		connection.executeUpdate("INSERT INTO User VALUES (19, 'AlonzoC@williams-sonomainc.com', 'AlonzoC@williams-sonomainc.com', 'Carol', 'Alonzo');");
		connection.executeUpdate("INSERT INTO User VALUES (20, 'AranoE@intel.com', 'AranoE@intel.com', 'Elisha', 'Arano');");
		connection.executeUpdate("INSERT INTO User VALUES (21, 'BAronson@lithia.com', 'BAronson@lithia.com', 'Brett', 'Aronson');");
		connection.executeUpdate("INSERT INTO User VALUES (22, 'Kip_Arrocha@wellsfargo.com', 'Kip_Arrocha@wellsfargo.com', 'Kip', 'Arrocha');");
		connection.executeUpdate("INSERT INTO User VALUES (23, 'Joan.Ash@google.com', 'Joan.Ash@google.com', 'Joan', 'Ash');");
		connection.executeUpdate("INSERT INTO User VALUES (24, 'Sherill.Aumen@mcclatchy.com', 'Sherill.Aumen@mcclatchy.com', 'Sherill', 'Aumen');");
		connection.executeUpdate("INSERT INTO User VALUES (25, 'FranklinAycox@cisco.com', 'FranklinAycox@cisco.com', 'Franklin', 'Aycox');");
		connection.executeUpdate("INSERT INTO User VALUES (26, 'Jeremy_Babineaux@nikebiz.com', 'Jeremy_Babineaux@nikebiz.com', 'Jeremy', 'Babineaux');");
		connection.executeUpdate("INSERT INTO User VALUES (27, 'Sandra.Baird@nordstrom.com', 'Sandra.Baird@nordstrom.com', 'Sandra', 'Baird');");
		connection.executeUpdate("INSERT INTO User VALUES (28, 'Kimberly.Baker@intel.com', 'Kimberly.Baker@intel.com', 'Kimberly', 'Baker');");
		connection.executeUpdate("INSERT INTO User VALUES (29, 'Richard.Baker@mckesson.com', 'Richard.Baker@mckesson.com', 'Richard', 'Baker');");
		connection.executeUpdate("INSERT INTO User VALUES (30, 'CarlBarker@portlandgeneral.com', 'CarlBarker@portlandgeneral.com', 'Carl', 'Barker');");
		connection.executeUpdate("INSERT INTO User VALUES (31, 'Kevin_Belcher@symantec.com', 'Kevin_Belcher@symantec.com', 'Kevin', 'Belcher');");
		connection.executeUpdate("INSERT INTO User VALUES (32, 'BenavidezM@varian.com', 'BenavidezM@varian.com', 'Miguel', 'Benavidez');");
		connection.executeUpdate("INSERT INTO User VALUES (33, 'BennettE@levistrauss.com', 'BennettE@levistrauss.com', 'Elizabeth', 'Bennett');");
		connection.executeUpdate("INSERT INTO User VALUES (34, 'RBobb@juniper.net', 'RBobb@juniper.net', 'Russell', 'Bobb');");
		connection.executeUpdate("INSERT INTO User VALUES (35, 'Debbie_Bojorquez@weyerhaeuser.com', 'Debbie_Bojorquez@weyerhaeuser.com', 'Debbie', 'Bojorquez');");
		connection.executeUpdate("INSERT INTO User VALUES (36, 'BomkampT@national.com', 'BomkampT@national.com', 'Travis', 'Bomkamp');");
		connection.executeUpdate("INSERT INTO User VALUES (37, 'BrindleyT@xilinx.com', 'BrindleyT@xilinx.com', 'Tony', 'Brindley');");
		connection.executeUpdate("INSERT INTO User VALUES (38, 'BrionesR@precast.com', 'BrionesR@precast.com', 'Roberta', 'Briones');");
		connection.executeUpdate("INSERT INTO User VALUES (39, 'BBrown@pugetenergy.com', 'BBrown@pugetenergy.com', 'Barbara', 'Brown');");
		connection.executeUpdate("INSERT INTO User VALUES (40, 'Jerry.Brunson@micron.com', 'Jerry.Brunson@micron.com', 'Jerry', 'Brunson');");
		connection.executeUpdate("INSERT INTO User VALUES (41, 'BuckleyE@chevron.com', 'BuckleyE@chevron.com', 'Eric', 'Buckley');");
		connection.executeUpdate("INSERT INTO User VALUES (42, 'BurnettJ@potlatchcorp.com', 'BurnettJ@potlatchcorp.com', 'Joan', 'Burnett');");
		connection.executeUpdate("INSERT INTO User VALUES (43, 'MCade@ea.com', 'MCade@ea.com', 'Marsha', 'Cade');");
		connection.executeUpdate("INSERT INTO User VALUES (44, 'Lindy.Cantua@synnex.com', 'Lindy.Cantua@synnex.com', 'Lindy', 'Cantua');");
		connection.executeUpdate("INSERT INTO User VALUES (45, 'CarlsonL@igt.com', 'CarlsonL@igt.com', 'Linda', 'Carlson');");
		connection.executeUpdate("INSERT INTO User VALUES (46, 'DCascio@delmonte.com', 'DCascio@delmonte.com', 'Duane', 'Cascio');");
		connection.executeUpdate("INSERT INTO User VALUES (47, 'Vada_Catalli@zionsbancorporation.com', 'Vada_Catalli@zionsbancorporation.com', 'Vada', 'Catalli');");
		connection.executeUpdate("INSERT INTO User VALUES (48, 'CestoneR@sierrapacificresources.com', 'CestoneR@sierrapacificresources.com', 'Rebbecca', 'Cestone');");
		connection.executeUpdate("INSERT INTO User VALUES (49, 'TommyChalker@safeway.com', 'TommyChalker@safeway.com', 'Tommy', 'Chalker');");
		connection.executeUpdate("INSERT INTO User VALUES (50, 'ChavezT@schnitzersteel.com', 'ChavezT@schnitzersteel.com', 'Toni', 'Chavez');");
		connection.executeUpdate("INSERT INTO User VALUES (51, 'Arthur_Church@google.com', 'Arthur_Church@google.com', 'Arthur', 'Church');");
		connection.executeUpdate("INSERT INTO User VALUES (52, 'EdwardCoffey@micron.com', 'EdwardCoffey@micron.com', 'Edward', 'Coffey');");
		connection.executeUpdate("INSERT INTO User VALUES (53, 'CollinsR@rossstores.com', 'CollinsR@rossstores.com', 'Richard', 'Collins');");
		connection.executeUpdate("INSERT INTO User VALUES (54, 'Robert_Cook@wellsfargo.com', 'Robert_Cook@wellsfargo.com', 'Robert', 'Cook');");
		connection.executeUpdate("INSERT INTO User VALUES (55, 'Joshua.Costa@ebay.com', 'Joshua.Costa@ebay.com', 'Joshua', 'Costa');");
		connection.executeUpdate("INSERT INTO User VALUES (56, 'Teresa_Cothern@delmonte.com', 'Teresa_Cothern@delmonte.com', 'Teresa', 'Cothern');");
		connection.executeUpdate("INSERT INTO User VALUES (57, 'ArthurCrouch@sandisk.com', 'ArthurCrouch@sandisk.com', 'Arthur', 'Crouch');");
		connection.executeUpdate("INSERT INTO User VALUES (58, 'Kenneth.Culley@coremark.com', 'Kenneth.Culley@coremark.com', 'Kenneth', 'Culley');");
		connection.executeUpdate("INSERT INTO User VALUES (59, 'AntioneCummings@rhi.com', 'AntioneCummings@rhi.com', 'Antione', 'Cummings');");
		connection.executeUpdate("INSERT INTO User VALUES (60, 'CDagres@urscorp.com', 'CDagres@urscorp.com', 'Camie', 'Dagres');");
		connection.executeUpdate("INSERT INTO User VALUES (61, 'JosephDavidson@delmonte.com', 'JosephDavidson@delmonte.com', 'Joseph', 'Davidson');");
		connection.executeUpdate("INSERT INTO User VALUES (62, 'DDemetris@ebay.com', 'DDemetris@ebay.com', 'Daren', 'Demetris');");
		connection.executeUpdate("INSERT INTO User VALUES (63, 'Randy_Deritis@kla-tencor.com', 'Randy_Deritis@kla-tencor.com', 'Randy', 'Deritis');");
		connection.executeUpdate("INSERT INTO User VALUES (64, 'DiazP@weyerhaeuser.com', 'DiazP@weyerhaeuser.com', 'Patricia', 'Diaz');");
		connection.executeUpdate("INSERT INTO User VALUES (65, 'Eddie.Doiron@wellsfargo.com', 'Eddie.Doiron@wellsfargo.com', 'Eddie', 'Doiron');");
		connection.executeUpdate("INSERT INTO User VALUES (66, 'Henry.Douyette@gilead.com', 'Henry.Douyette@gilead.com', 'Henry', 'Douyette');");
		connection.executeUpdate("INSERT INTO User VALUES (67, 'DowkerM@national.com', 'DowkerM@national.com', 'Malorie', 'Dowker');");
		connection.executeUpdate("INSERT INTO User VALUES (68, 'RaulEbert@mckesson.com', 'RaulEbert@mckesson.com', 'Raul', 'Ebert');");
		connection.executeUpdate("INSERT INTO User VALUES (69, 'EndresG@varian.com', 'EndresG@varian.com', 'Gabriel', 'Endres');");
		connection.executeUpdate("INSERT INTO User VALUES (70, 'FamagelttoA@mcclatchy.com', 'FamagelttoA@mcclatchy.com', 'Azalee', 'Famageltto');");
		connection.executeUpdate("INSERT INTO User VALUES (71, 'Bonita.Ficke@safeway.com', 'Bonita.Ficke@safeway.com', 'Bonita', 'Ficke');");
		connection.executeUpdate("INSERT INTO User VALUES (72, 'Anita.Field@rossstores.com', 'Anita.Field@rossstores.com', 'Anita', 'Field');");
		connection.executeUpdate("INSERT INTO User VALUES (73, 'Larry.Figueroa@pgecorp.com', 'Larry.Figueroa@pgecorp.com', 'Larry', 'Figueroa');");
		connection.executeUpdate("INSERT INTO User VALUES (74, 'Peter_Fisher@safeway.com', 'Peter_Fisher@safeway.com', 'Peter', 'Fisher');");
		connection.executeUpdate("INSERT INTO User VALUES (75, 'Edward.Floyd@safeway.com', 'Edward.Floyd@safeway.com', 'Edward', 'Floyd');");
		connection.executeUpdate("INSERT INTO User VALUES (76, 'ChristopherFox@levistrauss.com', 'ChristopherFox@levistrauss.com', 'Christopher', 'Fox');");
		connection.executeUpdate("INSERT INTO User VALUES (77, 'Wilbur_Fralick@delmonte.com', 'Wilbur_Fralick@delmonte.com', 'Wilbur', 'Fralick');");
		connection.executeUpdate("INSERT INTO User VALUES (78, 'Sonja_Gabel@schnitzersteel.com', 'Sonja_Gabel@schnitzersteel.com', 'Sonja', 'Gabel');");
		connection.executeUpdate("INSERT INTO User VALUES (79, 'Palmer_Gally@cisco.com', 'Palmer_Gally@cisco.com', 'Palmer', 'Gally');");
		connection.executeUpdate("INSERT INTO User VALUES (80, 'MarioGauthier@pgecorp.com', 'MarioGauthier@pgecorp.com', 'Mario', 'Gauthier');");
		connection.executeUpdate("INSERT INTO User VALUES (81, 'Emmett.Godyn@safeway.com', 'Emmett.Godyn@safeway.com', 'Emmett', 'Godyn');");
		connection.executeUpdate("INSERT INTO User VALUES (82, 'Michael.Gonzales@nikebiz.com', 'Michael.Gonzales@nikebiz.com', 'Michael', 'Gonzales');");
		connection.executeUpdate("INSERT INTO User VALUES (83, 'Allen.Grable@safeco.com', 'Allen.Grable@safeco.com', 'Allen', 'Grable');");
		connection.executeUpdate("INSERT INTO User VALUES (84, 'GraceC@kla-tencor.com', 'GraceC@kla-tencor.com', 'Charles', 'Grace');");
		connection.executeUpdate("INSERT INTO User VALUES (85, 'GregoryR@ea.com', 'GregoryR@ea.com', 'Robert', 'Gregory');");
		connection.executeUpdate("INSERT INTO User VALUES (86, 'JoseGriffin@longs.com', 'JoseGriffin@longs.com', 'Jose', 'Griffin');");
		connection.executeUpdate("INSERT INTO User VALUES (87, 'GrossoS@yahoo.com', 'GrossoS@yahoo.com', 'Sherrie', 'Grosso');");
		connection.executeUpdate("INSERT INTO User VALUES (88, 'Warren.Gunn@coremark.com', 'Warren.Gunn@coremark.com', 'Warren', 'Gunn');");
		connection.executeUpdate("INSERT INTO User VALUES (89, 'Roger.Harden@kla-tencor.com', 'Roger.Harden@kla-tencor.com', 'Roger', 'Harden');");
		connection.executeUpdate("INSERT INTO User VALUES (90, 'HarriganM@ebay.com', 'HarriganM@ebay.com', 'Marsha', 'Harrigan');");
		connection.executeUpdate("INSERT INTO User VALUES (91, 'JHarris@ebay.com', 'JHarris@ebay.com', 'John', 'Harris');");
		connection.executeUpdate("INSERT INTO User VALUES (92, 'John.Harris@gapinc.com', 'John.Harris@gapinc.com', 'John', 'Harris');");
		connection.executeUpdate("INSERT INTO User VALUES (93, 'Dan_Hasler@lithia.com', 'Dan_Hasler@lithia.com', 'Dan', 'Hasler');");
		connection.executeUpdate("INSERT INTO User VALUES (94, 'Gary.Hathaway@wellsfargo.com', 'Gary.Hathaway@wellsfargo.com', 'Gary', 'Hathaway');");
		connection.executeUpdate("INSERT INTO User VALUES (95, 'Richard.Helton@huntsman.com', 'Richard.Helton@huntsman.com', 'Richard', 'Helton');");
		connection.executeUpdate("INSERT INTO User VALUES (96, 'RHenderson@kla-tencor.com', 'RHenderson@kla-tencor.com', 'Robert', 'Henderson');");
		connection.executeUpdate("INSERT INTO User VALUES (97, 'CHensley@safeco.com', 'CHensley@safeco.com', 'Charles', 'Hensley');");
		connection.executeUpdate("INSERT INTO User VALUES (98, 'JamesHernandez@sierrapacificresources.com', 'JamesHernandez@sierrapacificresources.com', 'James', 'Hernandez');");
		connection.executeUpdate("INSERT INTO User VALUES (99, 'JamesHernandez@gilead.com', 'JamesHernandez@gilead.com', 'James', 'Hernandez');");
		connection.executeUpdate("INSERT INTO User VALUES (100, 'Van_Herrmann@levistrauss.com', 'Van_Herrmann@levistrauss.com', 'Van', 'Herrmann');");
		connection.executeUpdate("INSERT INTO User VALUES (101, 'HilgemanM@microsoft.com', 'HilgemanM@microsoft.com', 'Mei', 'Hilgeman');");
		connection.executeUpdate("INSERT INTO User VALUES (102, 'RogerHo@rhi.com', 'RogerHo@rhi.com', 'Roger', 'Ho');");
		connection.executeUpdate("INSERT INTO User VALUES (103, 'BurtHokkanen@sandisk.com', 'BurtHokkanen@sandisk.com', 'Burt', 'Hokkanen');");
		connection.executeUpdate("INSERT INTO User VALUES (104, 'KathyHolden@zionsbancorporation.com', 'KathyHolden@zionsbancorporation.com', 'Kathy', 'Holden');");
		connection.executeUpdate("INSERT INTO User VALUES (105, 'Linda.Holland@nikebiz.com', 'Linda.Holland@nikebiz.com', 'Linda', 'Holland');");
		connection.executeUpdate("INSERT INTO User VALUES (106, 'HolleyV@microsoft.com', 'HolleyV@microsoft.com', 'Victoria', 'Holley');");
		connection.executeUpdate("INSERT INTO User VALUES (107, 'FHolliday@zionsbancorporation.com', 'FHolliday@zionsbancorporation.com', 'Florence', 'Holliday');");
		connection.executeUpdate("INSERT INTO User VALUES (108, 'MarieHopkins@cisco.com', 'MarieHopkins@cisco.com', 'Marie', 'Hopkins');");
		connection.executeUpdate("INSERT INTO User VALUES (109, 'OtisHoraney@sanmina-sci.com', 'OtisHoraney@sanmina-sci.com', 'Otis', 'Horaney');");
		connection.executeUpdate("INSERT INTO User VALUES (110, 'LHorton@lithia.com', 'LHorton@lithia.com', 'Laura', 'Horton');");
		connection.executeUpdate("INSERT INTO User VALUES (111, 'HowellB@sierrapacificresources.com', 'HowellB@sierrapacificresources.com', 'Barbara', 'Howell');");
		connection.executeUpdate("INSERT INTO User VALUES (112, 'SHundley@juniper.net', 'SHundley@juniper.net', 'Sabrina', 'Hundley');");
		connection.executeUpdate("INSERT INTO User VALUES (113, 'ShawnHylton@weyerhaeuser.com', 'ShawnHylton@weyerhaeuser.com', 'Shawn', 'Hylton');");
		connection.executeUpdate("INSERT INTO User VALUES (114, 'Jennifer_Jackson@sanmina-sci.com', 'Jennifer_Jackson@sanmina-sci.com', 'Jennifer', 'Jackson');");
		connection.executeUpdate("INSERT INTO User VALUES (115, 'LindaJackson@ebay.com', 'LindaJackson@ebay.com', 'Linda', 'Jackson');");
		connection.executeUpdate("INSERT INTO User VALUES (116, 'TJackson@igt.com', 'TJackson@igt.com', 'Timothy', 'Jackson');");
		connection.executeUpdate("INSERT INTO User VALUES (117, 'JohnsonB@sanmina-sci.com', 'JohnsonB@sanmina-sci.com', 'Barbara', 'Johnson');");
		connection.executeUpdate("INSERT INTO User VALUES (118, 'BJohnson@sierrapacificresources.com', 'BJohnson@sierrapacificresources.com', 'Barbara', 'Johnson');");
		connection.executeUpdate("INSERT INTO User VALUES (119, 'JohnsonJ@ea.com', 'JohnsonJ@ea.com', 'John', 'Johnson');");
		connection.executeUpdate("INSERT INTO User VALUES (120, 'David_Jordan@sun.com', 'David_Jordan@sun.com', 'David', 'Jordan');");
		connection.executeUpdate("INSERT INTO User VALUES (121, 'KappsK@weyerhaeuser.com', 'KappsK@weyerhaeuser.com', 'Kandis', 'Kapps');");
		connection.executeUpdate("INSERT INTO User VALUES (122, 'Martin_Keane@starbucks.com', 'Martin_Keane@starbucks.com', 'Martin', 'Keane');");
		connection.executeUpdate("INSERT INTO User VALUES (123, 'Nathaniel.Keeler@sun.com', 'Nathaniel.Keeler@sun.com', 'Nathaniel', 'Keeler');");
		connection.executeUpdate("INSERT INTO User VALUES (124, 'Elsie_Killian@gapinc.com', 'Elsie_Killian@gapinc.com', 'Elsie', 'Killian');");
		connection.executeUpdate("INSERT INTO User VALUES (125, 'David.King@plumcreek.com', 'David.King@plumcreek.com', 'David', 'King');");
		connection.executeUpdate("INSERT INTO User VALUES (126, 'Kathy.Kinney@pacer-international.com', 'Kathy.Kinney@pacer-international.com', 'Kathy', 'Kinney');");
		connection.executeUpdate("INSERT INTO User VALUES (127, 'HKrumins@mckesson.com', 'HKrumins@mckesson.com', 'Heath', 'Krumins');");
		connection.executeUpdate("INSERT INTO User VALUES (128, 'JLake@cisco.com', 'JLake@cisco.com', 'Jose', 'Lake');");
		connection.executeUpdate("INSERT INTO User VALUES (129, 'Brian_Lane@intel.com', 'Brian_Lane@intel.com', 'Brian', 'Lane');");
		connection.executeUpdate("INSERT INTO User VALUES (130, 'Mark_Larson@symantec.com', 'Mark_Larson@symantec.com', 'Mark', 'Larson');");
		connection.executeUpdate("INSERT INTO User VALUES (131, 'Christine_Lawrence@google.com', 'Christine_Lawrence@google.com', 'Christine', 'Lawrence');");
		connection.executeUpdate("INSERT INTO User VALUES (132, 'LeeC@ebay.com', 'LeeC@ebay.com', 'Carolyn', 'Lee');");
		connection.executeUpdate("INSERT INTO User VALUES (133, 'RobertLewis@google.com', 'RobertLewis@google.com', 'Robert', 'Lewis');");
		connection.executeUpdate("INSERT INTO User VALUES (134, 'WilliamLewis@xilinx.com', 'WilliamLewis@xilinx.com', 'William', 'Lewis');");
		connection.executeUpdate("INSERT INTO User VALUES (135, 'Charles.Lin@micron.com', 'Charles.Lin@micron.com', 'Charles', 'Lin');");
		connection.executeUpdate("INSERT INTO User VALUES (136, 'LingH@sandisk.com', 'LingH@sandisk.com', 'Herbert', 'Ling');");
		connection.executeUpdate("INSERT INTO User VALUES (138, 'LongM@varian.com', 'LongM@varian.com', 'Michelle', 'Long');");
		connection.executeUpdate("INSERT INTO User VALUES (137, 'DonaldLong@safeco.com', 'DonaldLong@safeco.com', 'Donald', 'Long');");
		connection.executeUpdate("INSERT INTO User VALUES (139, 'DLorah@google.com', 'DLorah@google.com', 'Dwain', 'Lorah');");
		connection.executeUpdate("INSERT INTO User VALUES (140, 'RobinLund@pgecorp.com', 'RobinLund@pgecorp.com', 'Robin', 'Lund');");
		connection.executeUpdate("INSERT INTO User VALUES (141, 'LutherG@spansion.com', 'LutherG@spansion.com', 'Glenn', 'Luther');");
		connection.executeUpdate("INSERT INTO User VALUES (142, 'Glenn_Mainland@nvidia.com', 'Glenn_Mainland@nvidia.com', 'Glenn', 'Mainland');");
		connection.executeUpdate("INSERT INTO User VALUES (143, 'MarcumJ@national.com', 'MarcumJ@national.com', 'Jose', 'Marcum');");
		connection.executeUpdate("INSERT INTO User VALUES (144, 'MartinR@yahoo.com', 'MartinR@yahoo.com', 'Robert', 'Martin');");
		connection.executeUpdate("INSERT INTO User VALUES (145, 'JMartinez@mckesson.com', 'JMartinez@mckesson.com', 'John', 'Martinez');");
		connection.executeUpdate("INSERT INTO User VALUES (146, 'TMcQueen@juniper.net', 'TMcQueen@juniper.net', 'Tiffany', 'McQueen');");
		connection.executeUpdate("INSERT INTO User VALUES (147, 'RodMeggett@wellsfargo.com', 'RodMeggett@wellsfargo.com', 'Rod', 'Meggett');");
		connection.executeUpdate("INSERT INTO User VALUES (148, 'MarjorieMejia@lithia.com', 'MarjorieMejia@lithia.com', 'Marjorie', 'Mejia');");
		connection.executeUpdate("INSERT INTO User VALUES (149, 'AngelaMendoza@rossstores.com', 'AngelaMendoza@rossstores.com', 'Angela', 'Mendoza');");
		connection.executeUpdate("INSERT INTO User VALUES (150, 'MerriweatherA@xilinx.com', 'MerriweatherA@xilinx.com', 'Adriana', 'Merriweather');");
		connection.executeUpdate("INSERT INTO User VALUES (151, 'Ruth.Miles@delmonte.com', 'Ruth.Miles@delmonte.com', 'Ruth', 'Miles');");
		connection.executeUpdate("INSERT INTO User VALUES (152, 'JamesMiller@symantec.com', 'JamesMiller@symantec.com', 'James', 'Miller');");
		connection.executeUpdate("INSERT INTO User VALUES (153, 'JMiller@xilinx.com', 'JMiller@xilinx.com', 'James', 'Miller');");
		connection.executeUpdate("INSERT INTO User VALUES (154, 'John.Miller@gapinc.com', 'John.Miller@gapinc.com', 'John', 'Miller');");
		connection.executeUpdate("INSERT INTO User VALUES (155, 'MillerJ@lsi.com', 'MillerJ@lsi.com', 'John', 'Miller');");
		connection.executeUpdate("INSERT INTO User VALUES (156, 'John.Miller@xilinx.com', 'John.Miller@xilinx.com', 'John', 'Miller');");
		connection.executeUpdate("INSERT INTO User VALUES (157, 'BenjaminMillsap@wellsfargo.com', 'BenjaminMillsap@wellsfargo.com', 'Benjamin', 'Millsap');");
		connection.executeUpdate("INSERT INTO User VALUES (158, 'James.Moldenhauer@questar.com', 'James.Moldenhauer@questar.com', 'James', 'Moldenhauer');");
		connection.executeUpdate("INSERT INTO User VALUES (159, 'MorrisonJ@plumcreek.com', 'MorrisonJ@plumcreek.com', 'Janet', 'Morrison');");
		connection.executeUpdate("INSERT INTO User VALUES (160, 'MMorrow@wellsfargo.com', 'MMorrow@wellsfargo.com', 'Margaret', 'Morrow');");
		connection.executeUpdate("INSERT INTO User VALUES (161, 'DorothyMurphy@juniper.net', 'DorothyMurphy@juniper.net', 'Dorothy', 'Murphy');");
		connection.executeUpdate("INSERT INTO User VALUES (162, 'Sharon.Murphy@lithia.com', 'Sharon.Murphy@lithia.com', 'Sharon', 'Murphy');");
		connection.executeUpdate("INSERT INTO User VALUES (163, 'NethertonB@yahoo.com', 'NethertonB@yahoo.com', 'Brad', 'Netherton');");
		connection.executeUpdate("INSERT INTO User VALUES (164, 'NoiaJ@ebay.com', 'NoiaJ@ebay.com', 'Jacob', 'Noia');");
		connection.executeUpdate("INSERT INTO User VALUES (165, 'NovitskeA@plumcreek.com', 'NovitskeA@plumcreek.com', 'Aldo', 'Novitske');");
		connection.executeUpdate("INSERT INTO User VALUES (166, 'Paul_Nunez@rossstores.com', 'Paul_Nunez@rossstores.com', 'Paul', 'Nunez');");
		connection.executeUpdate("INSERT INTO User VALUES (167, 'Bethel_Olson@delmonte.com', 'Bethel_Olson@delmonte.com', 'Bethel', 'Olson');");
		connection.executeUpdate("INSERT INTO User VALUES (168, 'Charles_Olson@williams-sonomainc.com', 'Charles_Olson@williams-sonomainc.com', 'Charles', 'Olson');");
		connection.executeUpdate("INSERT INTO User VALUES (169, 'Frances.Olson@hp.com', 'Frances.Olson@hp.com', 'Frances', 'Olson');");
		connection.executeUpdate("INSERT INTO User VALUES (170, 'EmmaOviedo@micron.com', 'EmmaOviedo@micron.com', 'Emma', 'Oviedo');");
		connection.executeUpdate("INSERT INTO User VALUES (171, 'SharonPainter@pgecorp.com', 'SharonPainter@pgecorp.com', 'Sharon', 'Painter');");
		connection.executeUpdate("INSERT INTO User VALUES (172, 'Jospeh.Palombo@paccar.com', 'Jospeh.Palombo@paccar.com', 'Jospeh', 'Palombo');");
		connection.executeUpdate("INSERT INTO User VALUES (173, 'Karen_Parker@chevron.com', 'Karen_Parker@chevron.com', 'Karen', 'Parker');");
		connection.executeUpdate("INSERT INTO User VALUES (174, 'CarrollParmely@synnex.com', 'CarrollParmely@synnex.com', 'Carroll', 'Parmely');");
		connection.executeUpdate("INSERT INTO User VALUES (175, 'EugenioPelis@delmonte.com', 'EugenioPelis@delmonte.com', 'Eugenio', 'Pelis');");
		connection.executeUpdate("INSERT INTO User VALUES (176, 'GeorgePineda@pugetenergy.com', 'GeorgePineda@pugetenergy.com', 'George', 'Pineda');");
		connection.executeUpdate("INSERT INTO User VALUES (177, 'PlumbM@starbucks.com', 'PlumbM@starbucks.com', 'Mario', 'Plumb');");
		connection.executeUpdate("INSERT INTO User VALUES (178, 'JeanPonce@lithia.com', 'JeanPonce@lithia.com', 'Jean', 'Ponce');");
		connection.executeUpdate("INSERT INTO User VALUES (179, 'JPowell@urscorp.com', 'JPowell@urscorp.com', 'James', 'Powell');");
		connection.executeUpdate("INSERT INTO User VALUES (180, 'PowellM@gapinc.com', 'PowellM@gapinc.com', 'Margaret', 'Powell');");
		connection.executeUpdate("INSERT INTO User VALUES (181, 'Jules.Powers@ebay.com', 'Jules.Powers@ebay.com', 'Jules', 'Powers');");
		connection.executeUpdate("INSERT INTO User VALUES (182, 'David.Price@intuit.com', 'David.Price@intuit.com', 'David', 'Price');");
		connection.executeUpdate("INSERT INTO User VALUES (183, 'IRhoda@levistrauss.com', 'IRhoda@levistrauss.com', 'Iona', 'Rhoda');");
		connection.executeUpdate("INSERT INTO User VALUES (184, 'DRice@rossstores.com', 'DRice@rossstores.com', 'Diane', 'Rice');");
		connection.executeUpdate("INSERT INTO User VALUES (185, 'JRichmond@pgecorp.com', 'JRichmond@pgecorp.com', 'Judy', 'Richmond');");
		connection.executeUpdate("INSERT INTO User VALUES (186, 'Steven_Ritter@microsoft.com', 'Steven_Ritter@microsoft.com', 'Steven', 'Ritter');");
		connection.executeUpdate("INSERT INTO User VALUES (187, 'MarthaRoach@pgecorp.com', 'MarthaRoach@pgecorp.com', 'Martha', 'Roach');");
		connection.executeUpdate("INSERT INTO User VALUES (188, 'SaraRoach@hp.com', 'SaraRoach@hp.com', 'Sara', 'Roach');");
		connection.executeUpdate("INSERT INTO User VALUES (189, 'John_Rodriguez@expediainc.com', 'John_Rodriguez@expediainc.com', 'John', 'Rodriguez');");
		connection.executeUpdate("INSERT INTO User VALUES (190, 'JohnRodriguez@longs.com', 'JohnRodriguez@longs.com', 'John', 'Rodriguez');");
		connection.executeUpdate("INSERT INTO User VALUES (191, 'Juliana.Rohe@rossstores.com', 'Juliana.Rohe@rossstores.com', 'Juliana', 'Rohe');");
		connection.executeUpdate("INSERT INTO User VALUES (192, 'CaroleRohrer@igt.com', 'CaroleRohrer@igt.com', 'Carole', 'Rohrer');");
		connection.executeUpdate("INSERT INTO User VALUES (193, 'DuaneRothe@sun.com', 'DuaneRothe@sun.com', 'Duane', 'Rothe');");
		connection.executeUpdate("INSERT INTO User VALUES (194, 'RubyS@intel.com', 'RubyS@intel.com', 'Sonya', 'Ruby');");
		connection.executeUpdate("INSERT INTO User VALUES (195, 'Yee.Rutenberg@urscorp.com', 'Yee.Rutenberg@urscorp.com', 'Yee', 'Rutenberg');");
		connection.executeUpdate("INSERT INTO User VALUES (196, 'KSainz@safeco.com', 'KSainz@safeco.com', 'Kenneth', 'Sainz');");
		connection.executeUpdate("INSERT INTO User VALUES (197, 'Elmer.Salter@yahoo.com', 'Elmer.Salter@yahoo.com', 'Elmer', 'Salter');");
		connection.executeUpdate("INSERT INTO User VALUES (198, 'BrandySegarra@levistrauss.com', 'BrandySegarra@levistrauss.com', 'Brandy', 'Segarra');");
		connection.executeUpdate("INSERT INTO User VALUES (199, 'ClaudiaSemidey@gapinc.com', 'ClaudiaSemidey@gapinc.com', 'Claudia', 'Semidey');");
		connection.executeUpdate("INSERT INTO User VALUES (200, 'ShultzH@cisco.com', 'ShultzH@cisco.com', 'Howard', 'Shultz');");
		connection.executeUpdate("INSERT INTO User VALUES (201, 'Marguerite.Shuman@national.com', 'Marguerite.Shuman@national.com', 'Marguerite', 'Shuman');");
		connection.executeUpdate("INSERT INTO User VALUES (202, 'ShuskeyR@costco.com', 'ShuskeyR@costco.com', 'Roberto', 'Shuskey');");
		connection.executeUpdate("INSERT INTO User VALUES (203, 'DSilva@expeditors.com', 'DSilva@expeditors.com', 'Diane', 'Silva');");
		connection.executeUpdate("INSERT INTO User VALUES (204, 'JerrellSimonetta@delmonte.com', 'JerrellSimonetta@delmonte.com', 'Jerrell', 'Simonetta');");
		connection.executeUpdate("INSERT INTO User VALUES (205, 'TSimpson@schnitzersteel.com', 'TSimpson@schnitzersteel.com', 'Thomas', 'Simpson');");
		connection.executeUpdate("INSERT INTO User VALUES (206, 'MSmith@con-way.com', 'MSmith@con-way.com', 'Michael', 'Smith');");
		connection.executeUpdate("INSERT INTO User VALUES (207, 'RonSmothers@safeco.com', 'RonSmothers@safeco.com', 'Ron', 'Smothers');");
		connection.executeUpdate("INSERT INTO User VALUES (208, 'Melvin_Sonterre@pugetenergy.com', 'Melvin_Sonterre@pugetenergy.com', 'Melvin', 'Sonterre');");
		connection.executeUpdate("INSERT INTO User VALUES (209, 'MichaelSosa@longs.com', 'MichaelSosa@longs.com', 'Michael', 'Sosa');");
		connection.executeUpdate("INSERT INTO User VALUES (210, 'RSpeights@utstar.com', 'RSpeights@utstar.com', 'Richard', 'Speights');");
		connection.executeUpdate("INSERT INTO User VALUES (211, 'RyanStarcher@delmonte.com', 'RyanStarcher@delmonte.com', 'Ryan', 'Starcher');");
		connection.executeUpdate("INSERT INTO User VALUES (212, 'AndreStickney@con-way.com', 'AndreStickney@con-way.com', 'Andre', 'Stickney');");
		connection.executeUpdate("INSERT INTO User VALUES (213, 'CStone@pacer-international.com', 'CStone@pacer-international.com', 'Christopher', 'Stone');");
		connection.executeUpdate("INSERT INTO User VALUES (214, 'Abigail.Stoneman@pgecorp.com', 'Abigail.Stoneman@pgecorp.com', 'Abigail', 'Stoneman');");
		connection.executeUpdate("INSERT INTO User VALUES (215, 'DSuarez@sierrapacificresources.com', 'DSuarez@sierrapacificresources.com', 'Donald', 'Suarez');");
		connection.executeUpdate("INSERT INTO User VALUES (216, 'James.Sullivan@chevron.com', 'James.Sullivan@chevron.com', 'James', 'Sullivan');");
		connection.executeUpdate("INSERT INTO User VALUES (217, 'Rita_Swanson@cisco.com', 'Rita_Swanson@cisco.com', 'Rita', 'Swanson');");
		connection.executeUpdate("INSERT INTO User VALUES (218, 'RSweet@pugetenergy.com', 'RSweet@pugetenergy.com', 'Richard', 'Sweet');");
		connection.executeUpdate("INSERT INTO User VALUES (219, 'Milton_Talamantez@netapp.com', 'Milton_Talamantez@netapp.com', 'Milton', 'Talamantez');");
		connection.executeUpdate("INSERT INTO User VALUES (220, 'Michael_Tarr@chubb.com', 'Michael_Tarr@chubb.com', 'Michael', 'Tarr');");
		connection.executeUpdate("INSERT INTO User VALUES (221, 'DTaylor@schnitzersteel.com', 'DTaylor@schnitzersteel.com', 'David', 'Taylor');");
		connection.executeUpdate("INSERT INTO User VALUES (222, 'GThill@nikebiz.com', 'GThill@nikebiz.com', 'Gary', 'Thill');");
		connection.executeUpdate("INSERT INTO User VALUES (223, 'JohnThompson@safeco.com', 'JohnThompson@safeco.com', 'John', 'Thompson');");
		connection.executeUpdate("INSERT INTO User VALUES (224, 'TorresD@utstar.com', 'TorresD@utstar.com', 'Daniel', 'Torres');");
		connection.executeUpdate("INSERT INTO User VALUES (225, 'SudieTredinnick@sanmina-sci.com', 'SudieTredinnick@sanmina-sci.com', 'Sudie', 'Tredinnick');");
		connection.executeUpdate("INSERT INTO User VALUES (226, 'RonaldTrent@con-way.com', 'RonaldTrent@con-way.com', 'Ronald', 'Trent');");
		connection.executeUpdate("INSERT INTO User VALUES (227, 'TuM@sanmina-sci.com', 'TuM@sanmina-sci.com', 'Mark', 'Tu');");
		connection.executeUpdate("INSERT INTO User VALUES (228, 'Janiece.Unthank@google.com', 'Janiece.Unthank@google.com', 'Janiece', 'Unthank');");
		connection.executeUpdate("INSERT INTO User VALUES (229, 'ElvinVacio@franklintempleton.com', 'ElvinVacio@franklintempleton.com', 'Elvin', 'Vacio');");
		connection.executeUpdate("INSERT INTO User VALUES (230, 'Emilee_Valiente@thecloroxcompany.com', 'Emilee_Valiente@thecloroxcompany.com', 'Emilee', 'Valiente');");
		connection.executeUpdate("INSERT INTO User VALUES (231, 'SteveVanmeter@ebay.com', 'SteveVanmeter@ebay.com', 'Steve', 'Vanmeter');");
		connection.executeUpdate("INSERT INTO User VALUES (232, 'Joe.Varner@sierrapacificresources.com', 'Joe.Varner@sierrapacificresources.com', 'Joe', 'Varner');");
		connection.executeUpdate("INSERT INTO User VALUES (233, 'KennethVasquez@portlandgeneral.com', 'KennethVasquez@portlandgeneral.com', 'Kenneth', 'Vasquez');");
		connection.executeUpdate("INSERT INTO User VALUES (234, 'Mandy_Vince@microsoft.com', 'Mandy_Vince@microsoft.com', 'Mandy', 'Vince');");
		connection.executeUpdate("INSERT INTO User VALUES (235, 'HenryVuolo@nordstrom.com', 'HenryVuolo@nordstrom.com', 'Henry', 'Vuolo');");
		connection.executeUpdate("INSERT INTO User VALUES (236, 'LWaldmann@juniper.net', 'LWaldmann@juniper.net', 'Leone', 'Waldmann');");
		connection.executeUpdate("INSERT INTO User VALUES (237, 'CWard@coremark.com', 'CWard@coremark.com', 'Catherine', 'Ward');");
		connection.executeUpdate("INSERT INTO User VALUES (238, 'Vanda_Warnell@levistrauss.com', 'Vanda_Warnell@levistrauss.com', 'Vanda', 'Warnell');");
		connection.executeUpdate("INSERT INTO User VALUES (239, 'CWeathersby@nvidia.com', 'CWeathersby@nvidia.com', 'Catherine', 'Weathersby');");
		connection.executeUpdate("INSERT INTO User VALUES (240, 'HWedlock@intuit.com', 'HWedlock@intuit.com', 'Harland', 'Wedlock');");
		connection.executeUpdate("INSERT INTO User VALUES (241, 'JamesWhite@expediainc.com', 'JamesWhite@expediainc.com', 'James', 'White');");
		connection.executeUpdate("INSERT INTO User VALUES (242, 'TWhittler@chubb.com', 'TWhittler@chubb.com', 'Tyesha', 'Whittler');");
		connection.executeUpdate("INSERT INTO User VALUES (243, 'Paula_Williams@portlandgeneral.com', 'Paula_Williams@portlandgeneral.com', 'Paula', 'Williams');");
		connection.executeUpdate("INSERT INTO User VALUES (244, 'Robert_Williams@symantec.com', 'Robert_Williams@symantec.com', 'Robert', 'Williams');");
		connection.executeUpdate("INSERT INTO User VALUES (245, 'Linda_Wilson@thecloroxcompany.com', 'Linda_Wilson@thecloroxcompany.com', 'Linda', 'Wilson');");
		connection.executeUpdate("INSERT INTO User VALUES (246, 'JeraldWisz@hp.com', 'JeraldWisz@hp.com', 'Jerald', 'Wisz');");
		connection.executeUpdate("INSERT INTO User VALUES (247, 'TWooden@micron.com', 'TWooden@micron.com', 'Tommy', 'Wooden');");
		connection.executeUpdate("INSERT INTO User VALUES (248, 'Donna_Young@micron.com', 'Donna_Young@micron.com', 'Donna', 'Young');");
		connection.executeUpdate("INSERT INTO User VALUES (249, 'SebastianZizza@microsoft.com', 'SebastianZizza@microsoft.com', 'Sebastian', 'Zizza');");
		resetIdSequence(connection, "User");
	}
	
	/**
	 * Inserts the seed roles into the database.
	 * 
	 * @param connection The connection to use for the seed data run.
	 */
	public static void seedRoles(BPDatabaseConnection connection)
	{
		connection.executeUpdate("INSERT INTO Role VALUES (null, 'Author');"); // Id = 1
		connection.executeUpdate("INSERT INTO Role VALUES (null, 'Reviewer');"); // Id = 2
		connection.executeUpdate("INSERT INTO Role VALUES (null, 'Subprogram Chair');"); // Id = 3
		connection.executeUpdate("INSERT INTO Role VALUES (null, 'Program Chair');"); // Id = 4		
	}
		
	/**
	 * Inserts the seed permissions into the database.
	 * 
	 * @param connection The connection to use for the seed data run.
	 */
	public static void seedPermissions(BPDatabaseConnection connection)
	{
		// Program Chairs
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 152, 4);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 227, 4);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 62, 4);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 10, 64, 4);");
		
		// Subprogram Chairs
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 216, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 34, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 112, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 141, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 192, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 233, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 52, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 10, 89, 3);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 10, 56, 3);");
		
		// Reviewers
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 151, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 211, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 21, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 29, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 37, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 39, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 67, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 79, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 81, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 4, 105, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 8, 130, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 133, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 10, 186, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 9, 211, 2);");
		connection.executeUpdate("INSERT INTO Permission VALUES (null, 10, 17, 2);");
	}
	
	public static void main(String... args)
	{
		String dbFileName = "PaperReviewsDatabaseTest.sqlite3";

		//Tell the DB library what the DB file is
		BPDatabaseConnection connection = new BPSQLiteConnection(dbFileName);
		
		//Open the DB file
		connection.connect();
		
		//Initialize the DB tables
		initializeDatabase(connection);
		
		//Populate the seed roles into the DB
		seedRoles(connection);
		
		//Create some Users
		User newUser = new User();
		newUser.setEmail("test@test.com");
		newUser.setUsername("testUsername");
		newUser.setFirstName("TestFirstName");
		newUser.setLastName("TestLastName");
		
		User newUser2 = new User();
		newUser2.setEmail("test2@test.com");
		newUser2.setUsername("testUsername2");
		newUser2.setFirstName("TestFirstName2");
		newUser2.setLastName("TestLastName2");

		User newUser3 = new User();
		newUser3.setEmail("test3@test.com");
		newUser3.setUsername("testUsername3");
		newUser3.setFirstName("TestFirstName");
		newUser3.setLastName("TestLastName");
		
		//Create a UserClient to interact with the User table in the DB
		UserClient userClient = new UserClient(connection);
		
		//Persist the Users to the DB
		System.out.println(userClient.create(newUser));
		System.out.println(userClient.create(newUser2));
		System.out.println(userClient.create(newUser3));
		
		//Retrieve the Users by ID
		User storedUser = userClient.get(1);
		User storedUser2 = userClient.get(2);
		User storedUser3 = userClient.get(3);
		
		//Show that we got the correct data out of the DB
		System.out.println(storedUser.getEmail());
		System.out.println(storedUser2.getUsername());
		System.out.println(storedUser3.getFirstName());
		
		//Set up some queries for testing retrieval by query
		QueryBy[] queries = {new ById(1), new ByEmail("test@test.com")};
		QueryBy[] queries2 = {new ByLastName("TestLastName2")};
		QueryBy[] queries3 = {new ById(1), new ByUsername("bademail")};
		QueryBy[] queries4 = {new ByFirstName("TestFirstName")};
		
		//Run the queries
		User[] allUsers = userClient.getAll(queries);
		User[] allUsers2 = userClient.getAll(queries2);
		User[] allUsers3 = userClient.getAll(queries3);
		User[] allUsers4 = userClient.getAll(queries4);
		
		//Show that we got data for the first two getAll() calls, zero results from the third, and two from the fourth
		System.out.println(allUsers[0].getFirstName());
		System.out.println(allUsers2[0].getEmail());
		System.out.println(allUsers3.length);
		System.out.println(allUsers4.length);
		
		//Test updates on a specific field (other fields are null or zero)
		User updateUser = new User();
		updateUser.setId(3);
		updateUser.setFirstName("NewFirstName");
		userClient.update(updateUser);
		
		//Pull the updated User back
		updateUser = userClient.get(3);
		
		//Show that we still have the correct first name and that the retrieval succeeded since we got an e-mail address as well
		System.out.println(updateUser.getFirstName());
		System.out.println(updateUser.getEmail());
		
		//Test a deletion
		userClient.delete(storedUser3);
		
		User deletedUser = userClient.get(3);
		
		//Validate that the deleted user was unable to be retrieved
		if(deletedUser == null)
		{
			System.out.println("Deleted user was unable to be retrieved from the database.");
		}
		
		//Tests to make sure the date conversion works for conferences
		Conference conference = new Conference();
		
		conference.setTitle("Test Conference");
		conference.setDescription("Test Description");
		conference.setSubmitDeadline(System.currentTimeMillis());
		conference.setReviewDeadline(System.currentTimeMillis() + 86400000);
		conference.setRecommendDeadline(System.currentTimeMillis() + (86400000 * 2));
		conference.setAcceptDeadline(System.currentTimeMillis() + (86400000 * 3));
		conference.setUpdateDeadline(System.currentTimeMillis() + (86400000 * 4));
		
		ConferenceClient conferenceClient = new ConferenceClient(connection);
		
		conferenceClient.create(conference);
		
		Conference conference2 = conferenceClient.get(1);
		
		System.out.println(new Date(conference2.getSubmitDeadline()));
		
		//How to tell what roles somebody has
		//First, get a User
		//Note that there's nothing stopping two users from having the same username.
		//That sort of thing needs to be handled in the business rules that use these methods.
		
		QueryBy[] permissionTestUserQueries = {new ByUsername("testUsername")};
		
		User permissionTestUser = userClient.getAll(permissionTestUserQueries)[0];
		
		Permission permissionTestPermission = new Permission();

		//Giving somebody a program chair permission
		permissionTestPermission.setConferenceId(conference2.getId());
		permissionTestPermission.setUserId(permissionTestUser.getId());
		permissionTestPermission.setRoleId(Role.PROGRAM_CHAIR);
		
		PermissionClient permissionClient = new PermissionClient(connection);
		
		permissionClient.create(permissionTestPermission);
		
		//Let's give this user the author permission as well
		//Since the only thing that changes is the role ID, we can just change that and run create() again
		permissionTestPermission.setRoleId(Role.AUTHOR);
		
		permissionClient.create(permissionTestPermission);
		
		//Now, for retrieval
		QueryBy[] permissionTestPermissionQueries = {new ByConferenceId(conference2.getId()), new ByUserId(permissionTestUser.getId())};
		
		Permission[] permissionTestUserPermissions = permissionClient.getAll(permissionTestPermissionQueries);
		
		//Now print out the titles of the roles the person has for this conference
		RoleClient roleClient = new RoleClient(connection);
		
		for(Permission tempPermission : permissionTestUserPermissions)
		{
			System.out.println(roleClient.get(tempPermission.getId()).getTitle());
		}
		
		//Test to make sure we can get all the objects in a table back
		User[] allUsersTest = userClient.getAll(null);
		
		System.out.println(allUsersTest.length);
		
		connection.disconnect();
		
		//Set the seed data
		BPDatabaseConnection seedConnection = new BPSQLiteConnection("PaperReviews.sqlite3");
		
		seedConnection.connect();
		
		initializeDatabase(seedConnection);
		runSeedData(seedConnection);

		seedConnection.disconnect();
	}
}
